package com.smart.campus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.campus.dao.ShAskMapper;
import com.smart.campus.dto.ShAsk;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.service.ShAskService;
import com.smart.campus.util.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShAskServiceImpl implements ShAskService {
    @Autowired
    private ShAskMapper shAskMapper;

    @Override
    public List<ShAsk> findAskList() {
        return shAskMapper.selectList(null);
    }

    @Override
    public PagedResponse<ShAsk> pageShAsk(ShAsk shAsk, Integer pageNum, Integer pageSize) {
        Page<ShAsk> page = new Page<>(pageNum, pageSize);
        QueryWrapper<ShAsk> wrapper = new QueryWrapper<>();
        IPage<ShAsk> page1 = shAskMapper.pageShAsk(page,wrapper);
        return PaginationUtil.getPaginationResponse(page1.getRecords(),pageNum,pageSize,page1.getTotal());
    }
}
